# @Author：silence
# @Email：792245022@qq.com
# @Date：2025/2/25 2:35

from house import *


class HouseService:
    house_list = []

    def __init__(self):
        house = House(2, "tim", "113", "海淀", 800, "未出租")
        self.house_list.append(house)

    def get_house_list(self):
        """
        获取房屋列表
        :return:
        """
        return self.house_list

    def add_house(self, house: House):
        """
        添加房屋信息
        :return:
        """
        self.house_list.append(house)

    def del_by_id(self, del_id: int):
        house = self.find_by_id(del_id)
        if not house:
            return False
        self.house_list.remove(house)
        return True

    def find_by_id(self, del_id: int):
        """
        通过id查找对象
        :param del_id: 删除 ID
        :return: 没有返回 None
        """
        for house in self.house_list:
            if house.id == del_id:
                return house
        return None
